

import vaa = module("main/org/sdmx/model/v2/base/VersionableArtefactAdapter");
import ma = module("main/org/sdmx/model/v2/base/MaintainableArtefact");
import is = module("main/org/sdmx/model/v2/base/InternationalString");
import mac = module("main/org/sdmx/model/v2/structure/organisation/MaintenanceAgency");

/**
	* Default implementation of the MaintainableArtefact interface. 
	* This class exists as convenience for creating MaintainableArtefact 
	* objects.
	* 
	* @author Xavier Sosnovsky, Anthony Morel
	*/
export class MaintainableArtefactAdapter extends vaa.VersionableArtefactAdapter 
	implements ma.MaintainableArtefact {
			
	/*==============================Fields================================*/
		
	private _isFinal:bool;
		
	private _maintainer:mac.MaintenanceAgency;
		
	/*===========================Constructor==============================*/
				
	/**
		* Constructs a maintainable artefact.
		*  
		* @param id
		* 		The object identifier (e.g.: CL_FREQ)
		* @param objectName
		* 		The object name (e.g.: Frequency code list)
		* @param maintenanceAgency
		* 		The agency responsible for maintaining the object (e.g.: ECB)
		*/
	constructor(id:string, 
		objectName:is.InternationalString, maintenanceAgency:mac.MaintenanceAgency) 
	{
		super(id);
		this.setName(objectName);
        this.setMaintainer(maintenanceAgency);
	}
		
	/*============================Accessors===============================*/
		
	/**
		* @inheritDoc 
		*/
	public getMaintainer():mac.MaintenanceAgency {
		return this._maintainer;
	}
		
	/**
		* @inheritDoc 
		*/
	public setMaintainer(maintainer:mac.MaintenanceAgency) {
		if (null != maintainer) {
			this._maintainer = maintainer;
		} else {
			throw new Error("The maintenance agency cannot be " + 
					"null");
		}
	}
		
	/**
		* @inheritDoc 
		*/
	public getIsFinal():bool {
		return this._isFinal;
	}
		
	/**
		* @inheritDoc 
		*/
	public setIsFinal(isFinal:bool) {
		this._isFinal = isFinal;
	}
}